﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class LoginDAL
    {
        //登录
        //public static List<Login> SelectLogin(string UserName, string Pwd)
        //{
        //    string sql = "select * from UserInfo where UserName='" + UserName + "'and Pwd='" + Pwd + "'";
        //    SqlDataReader dr = Dbhelpr.Selectdata(sql);
        //    List<Login> ll = new List<Login>();
        //    while (dr.Read())
        //    {
        //        Login lo = new Login();
        //        lo.ID = (int)dr["ID"];
        //        lo.UserName = (string)dr["UserName"];
        //        lo.Pwd = (string)dr["Pwd"];
        //        lo.UserType = (int)dr["UserType"];
        //        ll.Add(lo);
        //    }
        //    dr.Close();
        //    return ll;
        //}

        public static List<Login> SelectLogin(string UserName, string Pwd)
        {
            string sql = "select * from UserInfo where UserName='" + UserName + "'and Pwd='" + Pwd + "'";
            DataTable dt = DBHelper.GetDataTable(sql);
            List<Login> ll = new List<Login>();
            foreach (DataRow dr in dt.Rows)
            {
                Login lo = new Login();
                lo.ID = (int)dr["ID"];
                lo.UserName = (string)dr["UserName"];
                lo.Pwd = (string)dr["Pwd"];
                lo.UserType = (int)dr["UserType"];
                ll.Add(lo);
            }
            return ll;
        }
    }
}
